/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-13 13:42:20
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-28 15:20:39
 * @FilePath: \adminstration\src\Common\Router\MenuNavList\Environmental\EnvironmentData.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import axios from 'axios'
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, MoreActionsButton } from '../Common/options'
import { Organizations } from '../Common/Conversion'

export const Sample = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        type: '试验事务',
        pageSize: 10,
        params: { pageIndex: 1, OSendTime: 'desc@1' },
        get: API_LIST()[`get${url}GetSampleList`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '354cf8bc-05b3-4321-b10e-5cc3af8c6e07') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增委托信息" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.SearchSort, selectType: 'Sample' },
            {
                dataIndex: 'sendTime',
                title: '送检日期',
                valueType: 'Date',
                showTime: true,
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'status',
                title: '检测状态',
                valueType: 'select',
                valueEnum: BuiltInData.SampleStatus,
                rules: true,
                hideInAdded: true,
                hideInModify: true,
                width: 150,
            },
            {
                dataIndex: 'standardModifyNo',
                title: '程序文件编号',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'taskNo',
                title: '任务单编号',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                width: 130,
            },
            {
                dataIndex: 'delegateNo',
                title: '委托书编号',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                width: 130,
            },
            {
                dataIndex: 'clientOrganization',
                title: '委托单位',
                valueType: 'input',
                rules: true,
                width: 250,
            },
            {
                dataIndex: 'engineeringName',
                title: '工程名称',
                valueType: 'input',
                width: 200,
            },
            {
                dataIndex: 'engineeringPurpose',
                title: '工程部位/用途',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'sourceType',
                title: '来样方式',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'testRequirement',
                title: '检验要求',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 300,
            },
            {
                dataIndex: 'testBasis',
                title: '试验依据',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'judgeBasis',
                title: '判定依据',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'securityLevel',
                title: '保密要求',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 300,
            },
            {
                dataIndex: 'sampleReceiveStatus',
                title: '样品接收情况',
                valueType: 'input',
                hideInSearch: true,
                width: 300,
            },
            {
                dataIndex: 'sampleStatus',
                title: '样品状态',
                valueType: 'input',
                hideInSearch: true,
                width: 300,
            },
            {
                dataIndex: 'sampleAdministrator',
                title: '样品管理员',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'sampleReceiver',
                title: '样品领取人',
                valueType: 'input',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 200,
            },
            {
                dataIndex: 'organizationUuid',
                title: '试验检测室',
                valueType: 'select',
                valueEnum: ClientData.organization,
                hideInAdded: true,
                hideInModify: true,
                width: 200,
            },
            {
                dataIndex: 'otherAttachment',
                title: '其他附件',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'receivingReport',
                title: '领取报告方式',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'paymentMethod',
                title: '付款方式',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'postalCode',
                title: '邮政编码',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'address',
                title: '地址',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'telephone',
                title: '联系电话',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'customerName',
                title: '经办人',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            commonTableList.StartTime,
            commonTableList.EndTime,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 260,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'fb1e77e0-e8bf-4a41-8532-2123c338745d') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '4576f81a-a111-4ed5-b9ed-b521594d5a98') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                        <MoreActionsButton
                            key="more"
                            title="检测流程"
                            data={{
                                record,
                                actionRef,
                                Permission,
                                OptionsEvent,
                                header: data.columns,
                                SampleA01: {
                                    type: 'openModel',
                                    smallTitle: '来样登记',
                                },
                                SampleA02: {
                                    type: 'openModel',
                                    smallTitle: '分配任务',
                                },
                                SampleA03: {
                                    type: 'openModel',
                                    smallTitle: '领样品',
                                },
                                SampleA04: {
                                    type: 'openModel',
                                    smallTitle: '样品检测',
                                },
                                SampleA05: {
                                    type: 'openModel',
                                    smallTitle: '审核报告',
                                },
                                SampleA06: {
                                    type: 'openModel',
                                    smallTitle: '样品管理',
                                },
                            }}
                            items={[
                                Permission.findIndex(v => v.uuid === 'fdc2130c-93ae-4dbe-8970-51725ab4e909') !== -1 && {
                                    key: 'SampleA01',
                                    label: '一、来样登记',
                                },
                                Permission.findIndex(v => v.uuid === '11f77a7a-6396-4605-8d46-64db9426a08c') !== -1 && {
                                    key: 'SampleA02',
                                    label: '二、分配任务',
                                },
                                Permission.findIndex(v => v.uuid === '68120e8d-ee33-4bf5-a428-abc113d8803b') !== -1 && {
                                    key: 'SampleA03',
                                    label: '三、领样品',
                                },
                                Permission.findIndex(v => v.uuid === '39c2bc3d-3789-46d5-8804-63e30f8f57c5') !== -1 && {
                                    key: 'SampleA04',
                                    label: '四、样品检测',
                                },
                                Permission.findIndex(v => v.uuid === 'fb914e57-551f-4f27-8240-d5d1ece1cbce') !== -1 && {
                                    key: 'SampleA05',
                                    label: '五、审核报告',
                                },
                                Permission.findIndex(v => v.uuid === '58f72385-065b-4711-852b-19e1311d5258') !== -1 && {
                                    key: 'SampleA06',
                                    label: '六、样品管理',
                                },
                            ]}
                        />,
                    ]
                },
            },
        ],
    }
    const { data: init } = await axios.get(API_LIST()['getSamplePreinstallList'])
    data.initialValues = init
    return data
}
